package tictactoe.game;


public class HvH extends AbstractController
{

    private int round;
    int count,emptyx,emptyy;
   
    //constructor,initialise grid
    public HvH(Model model)
    {
        super(model);
       //round =round+1;    
    }

    public void play(int player)
    {
    	
    }
   
    //0 - valid move
    //-1 - position occupied
	//1 - player 1 wins
	//2 - player 2 wins
	//3 - Tie
    public int makeMove(int row, int col, int sign)
    {
        if (grid[row][col] <= 0) {
                grid[row][col] = sign;
        }
        else
        {
                
                return -1;
        }      
        //show();
        if (checkWon(grid))
         { return player+1;}
        else
        if (all==true) {return 3;}
        else
        {
                count = 0;
                for(int i=0;i<X;i++)
                        for(int j=0;j<Y;j++)
                                if (grid[i][j] <= 0) { count++;emptyx = i;emptyy = j;}
                if (count == 1)
                {
                        grid[emptyx][emptyy] = 1;
                        if (checkWon(grid)) { return 1;}
                        else { return 3;}
                }
        }
       
        player ^= 1;
        return 0;
     }

   
//    public int makeMove(int sign)
//    {
//      if (grid[X][Y] <= 0) {
//              grid[X][Y] = sign;
//              return 0;
//      }
//      if (grid[X][Y] !=0){
//              return 1;
//      }
//      
//      if (grid[X][Y] >0){
//              return 2;
//      }
//      }
//      else
//      {
//              System.out.printf("position occupied\n");
//              play(0);
//              return;
//      }      
        //show();
//        if (checkWon(grid))
//         { System.out.printf("Player %d wins\n", player+1);return;}
//        else
//        if (all==true) { System.out.print("Tie\n");return;}
//        else
//        {
//              count = 0;
//              for(int i=0;i<X;i++)
//                      for(int j=0;j<Y;j++)
//                              if (grid[i][j] <= 0) { count++;emptyx = i;emptyy = j;}
//              if (count == 1)
//              {
//                      grid[emptyx][emptyy] = 1;
//                      if (checkWon(grid)) { System.out.printf("Player %d wins\n", 1);return;}
//                      else { System.out.printf("Tie");return;}}
    

  /*  public static void main(String[] args)
    {
        HvH game = new HvH();
        game.play(0);
    }*/
}